package com.dayou.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dayou.bean.Room;
import com.dayou.service.IRoomService;
import com.dayou.common.core.controller.BaseController;
import com.dayou.common.core.page.TableDataInfo;
import com.dayou.common.core.domain.AjaxResult;
import com.dayou.common.utils.poi.ExcelUtil;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 房间 信息操作处理
 * 
 * @author dayou
 * @date 2020-04-29
 */
@RestController
@RequestMapping("/room")
public class RoomController extends BaseController
{
	@Autowired
	private IRoomService roomService;
						
    /**
	 * 查询所有房间列表
	 */
	@PostMapping("/listAll")
	@ResponseBody
	public TableDataInfo listAll(Room room)
	{
		startPage();
        List<Room> list = roomService.selectRoomList(room);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出房间列表
	 */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Room room)
    {
    	List<Room> list = roomService.selectRoomList(room);
        ExcelUtil<Room> util = new ExcelUtil<Room>(Room.class);
        return util.exportExcel(list, "room");
    }

	/**
	 * 修改保存房间
	 */
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Room room)
	{		
		return toAjax(roomService.updateRoom(room));
	}
}
